package com.dcits.idea.dialog;

import com.dcits.idea.util.WebRequest;
import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;

/**
 * @Author tangmqb DCITS
 * @DATE 2021/11/3 9:08
 * @Version 1.0.0
 */
public class OpenDialog extends DialogWrapper {

    JLabel label = new JLabel();
    public OpenDialog() {
        super(true);
        setTitle("每天一杯毒鸡汤");
        init();

    }

    @Nullable
    @Override
    protected JComponent createCenterPanel() {
        JPanel panel = new JPanel();
//        http://rainbow.ilibrary.me/api/rainbow/random
        label.setText(WebRequest.getDuTang());
        panel.add(label);
        return panel;
    }

    @Override
    protected JComponent createSouthPanel() {
        JPanel panel = new JPanel();
        JButton jButton = new JButton("再来一碗");
        jButton.addActionListener(e -> {
            label.setText(WebRequest.getDuTang());
        });
        panel.add(jButton);
        return panel;
    }
}
